#include <iostream>
#include <vector>

using namespace std;

class Solution {
public:
    int distanceBetweenBusStops(vector<int>& distance, int start, int destination) {
        if (start > destination) {
            swap(start, destination);
        }
        int distance_out[2] = {0, 0};
        for (int i = 0; i < start; i++) {
            distance_out[1] += distance[i];
        }
        for (int i = start; i < destination; i++) {
            distance_out[0] += distance[i];
        }
        for (int i = destination; i < distance.size(); i++) {
            distance_out[1] += distance[i];
        }
        return min(distance_out[0], distance_out[1]);
    }
};

int main() {
    vector<int> input = {1, 2, 3, 4};
    Solution solution;
    int result = solution.distanceBetweenBusStops(input, 1, 0);
    std::cout << result << std::endl;
    return 0;
}